#ifndef _____WARD_SLIDERBAR_CPP
#define _____WARD_SLIDERBAR_CPP

#include "driver.h"
#include "sliderBar.h"

sliderBar::sliderBar(int x, int y, float l, float r, float s, int w, int h, int b)
 :uielement()
{
	this->xpos = x; 
	this->ypos = y; 

	this->height = h; 
	this->border = b; 
	this->width = w; 

	this->data = l; 
	this->leftB = l; 
	this->rightB = r; 
	this->step = s;
}

void sliderBar::drawDisabled()
{
	glColor4f(0.0,0.0,0.0,1.0);
		glRectf(xpos-border,ypos-border,xpos+width+border,ypos+width+border);
	glColor4f(0.4,0.4,0.4,1.0);
		glRectf(xpos,ypos,32,32);
	if(data == 1)
	{
		glColor4f(0.0,0.0,0.0,1.0);
		glLineWidth(2.0);
		glBegin(GL_LINES);
			glVertex2f(xpos, ypos);
			glVertex2f(xpos+width,ypos+width);
			glVertex2f(xpos+width, ypos);
			glVertex2f(xpos,ypos+width);
		glEnd();
	}
}

void sliderBar::drawEnabled(int xpos, int ypos)
{
	glColor4f(cSec[0],cSec[1],cSec[2],1.0);
		glRectf(xpos-border, ypos-border, xpos+width+3+border, ypos+height+border);
	glColor4f(cPri[0],cPri[1],cPri[2],1.0);
		glRectf(xpos,ypos+(height/5),xpos+width+3,ypos+(4*height/5));
	glColor4f(cTer[0],cTer[1],cTer[2],1.0);
//	cout << "Right: " << rightB << "\t" << "Left: " << leftB << "\t" << "Data: " << data << "Right-Left:" << rightB - leftB << endl;
//	cout << data /(rightB-leftB) * width<< endl;

		glRectf(xpos+((data/(rightB-leftB)))*width,
				ypos+(height/100),
				xpos+((data/(rightB-leftB)))*width+3,
				ypos+(99*height/100));
	
}

#endif